<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="perm" uri="/WEB-INF/tld/perm.tld"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<script>var ctx="${ctx}";</script>
<div class="form-horizontal" role="form" >
	<input type="hidden" id="token" name="token" value="<%=request.getAttribute("token") %>" />
    <input id="id" value="${newfind.id}"  type="hidden"/>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">标题:</label>
        <div class="col-md-9">
        	 <input id="title" value="${newfind.title}"  type="text" data-check="require:true;code:^[a-zA-Z0-9\u4e00-\u9fa5]{1,30};message:不能为空" placeholder="标题" class="form-control" name="title"/>
        </div>
    </div>
    <div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">分类:</label>
        <div class="col-md-9">
        	<select id="typeId" placeholder="选择分类" class="chosen-select full-width" tabindex="4">
			</select>
        </div>
    </div>
    
    
    
    	<div class="form-group">
	 	    <label class="col-md-3 col-sm-3 control-label">图片:</label>
	        <div class="col-md-9">
	        	 <input class="fileInput" id="imageUploadify" type="file" name="file" accept="image/*"/>
	        	 <div class="imageUploadify">   
					<c:if test="${not empty(newfind.image)}">
					<c:forEach items="${fn:split(newfind.image,',')}" var="i">
						<img src="${i}" style="width: 60px;height: 60px">
					</c:forEach>
					</c:if>
				 </div>
	        </div>
	   </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">新品链接:</label>
        <div class="col-md-9">
        	 <input id="url" value="${newfind.url}"  type="text" placeholder="新品链接" class="form-control" name="payMoney"/>
        </div>
    </div>
    <div class="form-group">
         <label class="col-md-3 col-sm-3 control-label">备注：</label>
         <div class="col-sm-9">
              <textarea id="content" style="resize:none"  placeholder="备注" class="form-control"  required="" aria-required="true">${newfind.content}</textarea>
         </div>
    </div>
<!--     <div class="form-group"> -->
<!--  	    <label class="col-md-3 col-sm-3 control-label">状态：</label> -->
<!--         <div class="col-md-9"> -->
<%--         	 	<input type="checkbox" class="js-switch" name="enabled" <c:if test="${announce.enabled==0 }"> checked="checked" </c:if>/> --%>
<!--         </div> -->
<!--     </div> -->
</div>

<script>

$(function(){
	jQuery.checkall(false);
})
var typeId="${newfind.typeId}";
$("#typeId").chosen({ width: '100%' });

$.ajax({  
	url:'${ctx}/newfindType/list',  		 					
	data:{						
	},   
	type: 'POST',
	dataType:'json',  
	success:function(response){
		if(response.code==0){
			var html=[];
			var data=response.data||[];
			for(var i=0;i<data.length;i++){
				html.push('<option value="'+data[i].id+'" ');
				html.push('>'+data[i].name+'</option>');
			}
			$("#typeId").append(html.join(""));
			$("#typeId").val(typeId);
			$("#typeId").trigger("chosen:updated");
		}
	}  
 });
 
	

	$("#imageUploadify").uploadify({
		'buttonImage':'${ctx}/static/js/plugins/uploadify/uploadify-button.png',
	    'swf': '${ctx}/static/js/plugins/uploadify/uploadify.swf',
	    'uploader':'${ctx}/file/uploadOss',
	    'multi':false,
	    'onFallback' : function() {//检测FLASH失败调用 
	    	alert("您未安装FLASH控件，无法上传图片！请安装FLASH控件后再试。");  
	    },  
	    'onUploadSuccess':function(file, data, response){
	    	var jData = jQuery.parseJSON(data);
	        $(".imageUploadify").append("<img src=\""+jData.data+"\" style=\"width: 60px;height: 60px;padding-left:5px;\">");
		}
	});
	
</script>